/*
 * allocations.h
 *
 * Created: 6/13/2013 4:26:51 AM
 *  Author: Tim
 */ 


#ifndef ALLOCATIONS_H_
#define ALLOCATIONS_H_

#include <avr/io.h>

enum Alloc
{
	FEATURE_FREE		= 0,
	FEATURE_UTILIZED	= 1
};

typedef enum TIMER_ALLOC
{
	TIMER_ALL_UTILIZED	= 0,
	TIMER_C0			= 1,
	TIMER_C1			= 2,
	TIMER_D0			= 3,
	TIMER_D1			= 4,
	TIMER_E0			= 5
}tmrAlloc_t;

typedef enum ENC_TMR_ALLOC
{
	ENC_UNALLOC			= 0,		//no timer has been allocated for the encoder. i.e. the encoder has not been initilixed
	ENC_TC0				= 1,		//encoder uses timer C0
	ENC_TC1				= 2,		//encoder uses timer C1
	ENC_TD0				= 3,		//encoder uses timer D0
	ENC_TD1				= 4,		//encoder uses timer D1
	ENC_TE0				= 5			//encoder uses timer E0
};

typedef struct DAQ_ALLOCATIONS
{
	
	struct dioAllocation1
	{
		uint8_t reserved		:2;
		uint8_t	dio13Alloc		:1;
		uint8_t	dio12Alloc		:1;
		uint8_t	dio11Alloc		:1;
		uint8_t	dio10Alloc		:1;
		uint8_t	dio9Alloc		:1;
		uint8_t	dio8Alloc		:1;
	}dioAlloc1;

	struct dioAllocation0
	{
		uint8_t	dio7Alloc		:1;
		uint8_t	dio6Alloc		:1;
		uint8_t	dio5Alloc		:1;
		uint8_t	dio4Alloc		:1;
		uint8_t	dio3Alloc		:1;
		uint8_t	dio2Alloc		:1;
		uint8_t	dio1Alloc		:1;
		uint8_t	dio0Alloc		:1;
	}dioAlloc0;
	
	struct timerAllocation
	{
		uint8_t reserved		:3;
		uint8_t timerE0Alloc	:1;
		uint8_t timerD1Alloc	:1;
		uint8_t timerD0Alloc	:1;
		uint8_t timerC1Alloc	:1;
		uint8_t timerC0Alloc	:1;
	}timerAlloc;
	
	struct analogAllocation
	{
		uint8_t reserved		:4;
		uint8_t analogCh3Alloc	:1;
		uint8_t analogCh2Alloc	:1;
		uint8_t analogCh1Alloc	:1;
		uint8_t analogCh0Alloc	:1;
	}analogAlloc;	
	
	struct encoderAllocations
	{
		uint8_t enc1Alloc		:1;
		uint8_t enc1TmrAlloc	:3;
		uint8_t enc0Alloc		:1;
		uint8_t enc0TmrAlloc	:3;
	}encAlloc;

	struct timerSourceAllocations
	{
		uint8_t source;
	}tmrC0_SRC, tmrC1_SRC, tmrD0_SRC, tmrD1_SRC, tmrE0_SRC;
	
}daqAlloc_t;					

daqAlloc_t daqAlloc;

#endif /* ALLOCATIONS_H_ */